package org.chupito.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.chupito.dao.DAO;
import org.chupito.search.SearchObject;

public abstract class DAOImpl<T> implements DAO<T> {

	@PersistenceContext
	private EntityManager em;

	public DAOImpl() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.chupito.dao.InvoiceDAO#create(org.chupito.data.Invoice)
	 */
	@Override
	public void create(T t) {
		em.persist(t);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.chupito.dao.InvoiceDAO#save(org.chupito.data.Invoice)
	 */
	@Override
	public void save(T t) {
			t = em.merge(t);
	}
	
	public abstract List<T> find(SearchObject t);
}
